# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=tlsdate
pkgver=0.0.13
pkgrel=7
pkgdesc="An secure parasitic rdate replacement"
url="https://github.com/ioerror/tlsdate"
arch="all"
license="BSD"
depends=""
depends_dev=""
pkgusers="tlsdate"
pkggroups="tlsdate"
# FIXME: does not support openssl 1.1 yet
makedepends="autoconf automake libtool libressl-dev linux-headers libevent-dev"
install=""
subpackages="$pkgname-doc"
source="tlsdate-${pkgver}.tar.gz::https://github.com/ioerror/tlsdate/tarball/tlsdate-${pkgver}
	tlsdate.confd
	tlsdate.initd
	tlsdated.confd
	tlsdated.initd
	tlsdate-add-secondary-archs.patch
	tlsdate-add-mips.patch
	libressl-no-sslv3.patch
	libressl-sslstate.patch
	"

builddir="$srcdir"/ioerror-tlsdate-ae33169

build() {
	cd "$builddir"
	autoreconf --install
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-static \
		--sysconfdir=/etc \
		--with-unpriv-user=tlsdate \
		--with-unpriv-group=tlsdate \
		|| return 1
	make || return 1
}

package() {
	cd "$builddir"
	make install DESTDIR="$pkgdir" || return 1
	install -Dm755 "$srcdir"/tlsdate.initd "$pkgdir"/etc/init.d/tlsdate
	install -Dm644 "$srcdir"/tlsdate.confd "$pkgdir"/etc/conf.d/tlsdate
	install -Dm755 "$srcdir"/tlsdated.initd "$pkgdir"/etc/init.d/tlsdated
	install -Dm644 "$srcdir"/tlsdated.confd "$pkgdir"/etc/conf.d/tlsdated
}

sha512sums="9c4fd51439976a8541fdf1bb70afa5333b43b2e43b801a65b3b1ac3e4a437fd3021ef2aaeeb13fc1ba63ccd119f6eff4c10e3a5a28cf0cfd96bbc7a174dbb789  tlsdate-0.0.13.tar.gz
62149e3a9f26a71624bd851780f92a41c9aaf138793b5da762aa3002bcc5a409686d1bbe687b4abf1fc2e12205720a3825d9603cab0b0d978c2d0fd41422efe7  tlsdate.confd
c54d11ead7ee5035e4829df92b23cd54a71535199844b4f64ecfa715d9838ef954e7c2434df0767bb32c8226448d2fa080180be76ed8e417d5fa6dfc9c08dce6  tlsdate.initd
38bd7d64473ab487eea2539b11a7acadfc3fa5a627fb12e78931b62c46d3ebedab4c75d56839b0dee9fd8f42d4b7ae9ace08ea3f58941b8e2d183828c6a4fef2  tlsdated.confd
9601ab4f9bd8870ed0c8e4f9dcbc32df902a5998ea6eeb8c40b8a8286515f35bf2d755784d267f78d53ac9baaf2d20051e99c35ceabe9d846d9a2a40cf135760  tlsdated.initd
03ebe29088f91eb45a13a467797c4f5a88233e2ebea957ca72012fe892dea1377b652f8aadaab865352a37d255df674f1abba09f6670bf8a9015aebfce89cf77  tlsdate-add-secondary-archs.patch
da5eb21058f1aeb9783db575434750e7c01b5372d1135f8e945da1f39c7eadfb3c2251163f40bebc53756482e9673160d99a912935b50fc743a9c3f91dfcf20f  tlsdate-add-mips.patch
513ccff7056c0764a5d821a90819a0e293921fafc3d0f9ba93e42564bac2b6d041599eb075dfe43cb5d760e67e3ae9f5a46d3359080284c3df1adb845463478b  libressl-no-sslv3.patch
251913739da7da0fdd6b5a597dbe1c8fa42ffc6714d6621922ce15f685eb89afd466015519ff700a2e28314f736cd5d4526e872adca98d6a2edad8c338691693  libressl-sslstate.patch"
